package com.qf.test;

import com.qf.mapper.UserMapper;
import com.qf.pojo.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Wy
 * @version V1.0
 * @Project MavenDemo
 * @Package com.qf.test
 * @Description:
 * @Date 2022/6/10 11:35
 */
//使用spring的测试环境来进行测试
@RunWith(SpringJUnit4ClassRunner.class)
//加载spring核心配置文件
@ContextConfiguration("classpath:applicationContext.xml")
public class testUser {
    @Autowired
    private UserMapper userMapper;

    @Test
    public void name() {
      /*  User user = userMapper.selectById(1);
        System.out.println(user);*/

       /* int i = userMapper.deleteById(17);
        System.out.println(i);*/
        User user = new User();
       user.setId(18);
        user.setName("ddddd");
        user.setPassword("123");
        user.setSex("男");
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            Date parse = sdf.parse("2021-02-01 00:00:00");
            user.setBirthday(parse);
            Date parse1 = sdf.parse("2021-02-01 00:00:00");
            user.setRegistTime(parse1);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        int insert = userMapper.insert(user);
        System.out.println(insert);
    }
}
